﻿#ifndef CAMERAMANAGEWIDGET_H
#define CAMERAMANAGEWIDGET_H

#include <QWidget>
#include <QGroupBox>
#include <QCheckBox>
#include <QRadioButton>
#include <QLabel>
#include <QComboBox>
#include <QPushButton>
#include <QSpinBox>
#include "CameraBase.h"
#include "QtUtils.h"
#include "GraphicsView.h"

class CameraManageWidget : public QGroupBox
{
    Q_OBJECT
public:
    CameraManageWidget(const QString& title = "", QWidget *parent = nullptr);
    ~CameraManageWidget();
    void addCamera(CameraBase* mapCam);
signals:
    void sigConfigChanged(const CameraConfig& config);
    void sigAddOne(const CameraConfig& config);
    void sigDeleteOne(const QString& name);
    void sigReadCamParam(const QString& name);
    void sigFrameSoftTrig(const QString& name);
public slots:
    void onSetConfig(const CameraConfig& config);
private:
    void setupUI();
    void initConnection();
    void checkCamType(const CameraConfig& config);
    void checkCamColor(const CameraConfig& config);
    CameraConfig getConfigFromUI();
private:
    QMap<QString, CameraBase*> mMapCam;
private:
    QComboBox* cbboxCamList;
    QComboBox* cbboxCamBrand;

    QPushButton* pbtnRead;
    QPushButton* pbtnSave;
    QPushButton* pbtnAdd;
    QPushButton* pbtnDelete;

    QSpinBox* spboxOffX;
    QSpinBox* spboxOffY;
    QSpinBox* spboxWidth;
    QSpinBox* spboxHeight;

    QCheckBox* chkboxReverseX;
    QCheckBox* chkboxReverseY;

    QComboBox* cbboxFrameTrigMode;
    QPushButton* pbtnFrameSoftTrig;
    QLabel* lblFrameTrigDelay;
    QSpinBox* spboxFrameTrigDelay;
    QLabel* lblLineTrigMode;
    QComboBox* cbboxLineTrigMode;

    QLabel* lblWbMode;
    QLabel* lblWBR;
    QLabel* lblWBG;
    QLabel* lblWBB;
    QComboBox* cbboxWbMode;
    QSpinBox* spboxWBR;
    QSpinBox* spboxWBG;
    QSpinBox* spboxWBB;

    QComboBox* cbboxExpMode;
    QLabel* lblExp;
    QDoubleSpinBox* dspboxExp;
    QComboBox* cbboxGainMode;
    QLabel* lblGain;
    QDoubleSpinBox* dspboxGain;

    QCheckBox* chkboxRateControl;
    QLabel* lblRate;
    QDoubleSpinBox* dspboxRate;

    QLabel* lblPreDiv;
    QLabel* lblMul;
    QLabel* lblPostDiv;
    QSpinBox* spboxPreDiv;
    QSpinBox* spboxMul;
    QSpinBox* spboxPostDiv;

    GraphicsView* mView;

};
#endif // CAMERAMANAGEWIDGET_H
